package com.xyht.sca_s.student_manage_system.modules.asset.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.asset.entity.SmsAssetCategoryManagement;
import com.xyht.sca_s.student_manage_system.modules.asset.entity.SmsAssetProcess;
import com.xyht.sca_s.student_manage_system.modules.asset.mapper.SmsAssetCategoryManagementMapper;
import com.xyht.sca_s.student_manage_system.modules.asset.mapper.SmsAssetProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class AssetProcessInit {
    @Autowired
    private SmsAssetProcessMapper smsAssetProcessMapper;

    private String[] assetArray = {"固定资产入库", "固定资产出库", "固定资产借用",
            "固定资产归还", "固定资产维修", "固定资产报废", "易耗品入库", "易耗品出库", "易耗品领用","物资采购"};

    @Bean(value = "processInit")
    public void processInit() {
        Integer processCount =
                smsAssetProcessMapper.selectCount(new QueryWrapper<>());
        if (processCount == 0){
            int type = 1;
            for (String processName:assetArray) {
                SmsAssetProcess smsAssetProcess = new SmsAssetProcess();
                smsAssetProcess.setProcessName(processName);
                smsAssetProcess.setProcessType(type);
                smsAssetProcessMapper.insert(smsAssetProcess);

                type++;
            }
        }
    }

}
